/**
 * 
 */
package edu.wpi.cs509.messages.client;

import edu.wpi.cs509.representation.ClientGame;

/**
 * This class implements the reply message for a create-game request.
 * @author sparadis
 *
 */
public class MsgJoinGameReply extends MsgAckReply {
	/**
	 * serializable version number
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The new client game. 
	 */
	protected ClientGame cgame;
	
	/**
	 * Constructor, takes cgame only, sets success to true.
	 * @param cgame - the update client game that was joined
	 */
	public MsgJoinGameReply(ClientGame cgame) {
		super(true, "");
		this.cgame = cgame;
	}
	
	/**
	 * Constructor.
	 * @param cgame - the update client game that was joined
	 * @param success - true if the requesting message succeeeded.
	 * @param errStr = error string if requesting message failed.
	 */
	public MsgJoinGameReply(ClientGame cgame, boolean success, String errStr) {
		super(success, errStr);
		this.cgame = cgame;
	}
	
	/**
	 * Give the client game to the client.
	 */
	public void rxExecute() {
		getCl().receiveStartNewGame(cgame, msgSucceeded(), getErrString());
	}

}
